home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / utils / unix / unzip-5.12 / unzip.h < prev    next >
C/C++ Source or Header  |  1994-08-22  |  60KB  |  1,803 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.   unzip.h
  4.  
  5.   This header file is used by all of the UnZip source files.  Its contents
  6.   are divided into seven more-or-less separate sections:  predefined macros,
  7.   OS-dependent includes, (mostly) OS-independent defines, typedefs, function 
  8.   prototypes (or "forward declarations," in the case of non-ANSI compilers),
  9.   macros, and global-variable declarations.
  10.  
  11.   ---------------------------------------------------------------------------*/
  12.  
  13.  
  14.  
  15. #ifndef __unzip_h   /* prevent multiple inclusions */
  16. #define __unzip_h
  17.  
  18. /*****************************************/
  19. /*  Predefined, Machine-specific Macros  */
  20. /*****************************************/
  21.  
  22. #if defined(__GO32__) && defined(unix)   /* MS-DOS extender:  NOT Unix */
  23. #  undef unix
  24. #endif
  25. #if (defined(__convex__) && !defined(__convexc__))
  26. #  define __convexc__
  27. #endif
  28.  
  29. #if defined(unix) || defined(M_XENIX) || defined(COHERENT) || defined(__hpux)
  30. #  ifndef UNIX
  31. #    define UNIX
  32. #  endif
  33. #endif /* unix || M_XENIX || COHERENT || __hpux */
  34. #if defined(__convexc__) || defined(MINIX)
  35. #  ifndef UNIX
  36. #    define UNIX
  37. #  endif
  38. #endif /* __convexc__ || MINIX */
  39.  
  40. #ifdef __COMPILER_KCC__
  41. #  include <c-env.h>
  42. #  ifdef SYS_T20
  43. #    define TOPS20
  44. #  endif
  45. #endif /* __COMPILER_KCC__ */
  46.  
  47. /* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */
  48. #ifdef __POWERC
  49. #  define __TURBOC__
  50. #  define MSDOS
  51. #endif /* __POWERC */
  52. #if defined(__MSDOS__) && (!defined(MSDOS))   /* just to make sure */
  53. #  define MSDOS
  54. #endif
  55.  
  56. #if defined(linux) && (!defined(LINUX))
  57. #  define LINUX
  58. #endif
  59.  
  60. /* use prototypes and ANSI libraries if __STDC__, or Microsoft or Borland C, or
  61.  * Silicon Graphics, or Convex?, or IBM C Set/2, or GNU gcc/emx, or Watcom C,
  62.  * or Macintosh, or Windows NT, or Sequent, or Atari.
  63.  */
  64. #if defined(__STDC__) || defined(MSDOS) || defined(sgi)
  65. #  ifndef PROTO
  66. #    define PROTO
  67. #  endif
  68. #  define MODERN
  69. #endif
  70. #if defined(__IBMC__) || defined(__EMX__) || defined(__WATCOMC__)
  71. #  ifndef PROTO
  72. #    define PROTO
  73. #  endif
  74. #  define MODERN
  75. #endif
  76. #if defined(THINK_C) || defined(MPW) || defined(WIN32) || defined(_SEQUENT_)
  77. #  ifndef PTX   /* Sequent running Dynix/ptx:  non-modern compiler */
  78. #    ifndef PROTO
  79. #      define PROTO
  80. #    endif
  81. #    define MODERN
  82. #  endif
  83. #endif
  84. #if defined(ATARI_ST) || defined(__BORLANDC__)  /* || defined(__convexc__) */
  85. #  ifndef PROTO
  86. #    define PROTO
  87. #  endif
  88. #  define MODERN
  89. #endif
  90.  
  91. /* turn off prototypes if requested */
  92. #if defined(NOPROTO) && defined(PROTO)
  93. #  undef PROTO
  94. #endif
  95.  
  96. /* used to remove arguments in function prototypes for non-ANSI C */
  97. #ifdef PROTO
  98. #  define OF(a) a
  99. #else
  100. #  define OF(a) ()
  101. #endif
  102.  
  103. /* bad or (occasionally?) missing stddef.h: */
  104. #if defined(M_XENIX) || defined(DNIX)
  105. #  define NO_STDDEF_H
  106. #endif
  107.  
  108. #if defined(apollo)          /* defines __STDC__ */
  109. #    define NO_STDLIB_H
  110. #endif /* apollo */
  111.  
  112. #ifdef DNIX
  113. #  define SYSV
  114. #  define SHORT_NAMES         /* 14-char limitation on path components */
  115. /* #  define FILENAME_MAX  14 */
  116. #  define FILENAME_MAX  NAME_MAX    /* GRR:  experiment */
  117. #endif
  118.  
  119. #if (defined(__SYSTEM_FIVE) || defined(M_SYSV) || defined(M_SYS5))
  120. #  ifndef SYSV
  121. #    define SYSV
  122. #  endif
  123. #endif /* __SYSTEM_FIVE || M_SYSV || M_SYS5 */
  124.  
  125. #if (defined(ultrix) || defined(bsd4_2) || defined(sun) || defined(pyr))
  126. #  if (!defined(BSD) && !defined(SYSV))
  127. #    define BSD
  128. #  endif
  129. #endif /* ultrix || bsd4_2 || sun || pyr */
  130. #if defined(__convexc__)
  131. #  if (!defined(BSD) && !defined(SYSV))
  132. #    define BSD
  133. #  endif
  134. #endif /* __convexc__ */
  135.  
  136. #ifdef pyr  /* Pyramid */
  137. #  ifdef BSD
  138. #    define pyr_bsd
  139. #    define USE_STRINGS_H    /* instead of more common string.h */
  140. #  endif
  141. #  define ZMEM            /* should ZMEM only be for BSD universe...? */
  142. #  define DECLARE_ERRNO   /*  (AT&T memcpy was claimed to be very slow) */
  143. #endif /* pyr */
  144.  
  145. #if (defined(CRAY) && defined(ZMEM))
  146. #  undef ZMEM
  147. #endif
  148.  
  149. /* stat() bug for Borland, Watcom, VAX C (also GNU?), and Atari ST MiNT on
  150.  * TOS filesystems:  returns 0 for wildcards!  (returns 0xffffffff on Minix
  151.  * filesystem or U: drive under Atari MiNT) */
  152. #if (defined(__TURBOC__) || defined(__WATCOMC__) || defined(VMS))
  153. #  define WILD_STAT_BUG
  154. #endif
  155. #if (defined(__MINT__))
  156. #  define WILD_STAT_BUG
  157. #endif
  158.  
  159. #ifdef WILD_STAT_BUG
  160. #  define SSTAT(path,pbuf) (iswild(path) || stat(path,pbuf))
  161. #else
  162. #  define SSTAT stat
  163. #endif
  164.  
  165. #ifdef REGULUS  /* returns the inode number on success(!)...argh argh argh */
  166. #  define stat(p,s) zstat(p,s)
  167. #endif
  168.  
  169. #define STRNICMP zstrnicmp
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176. /***************************/
  177. /*  OS-Dependent Includes  */
  178. /***************************/
  179.  
  180. #ifndef MINIX            /* Minix needs it after all the other includes (?) */
  181. #  include <stdio.h>
  182. #endif
  183. #include <ctype.h>       /* skip for VMS, to use tolower() function? */
  184. #include <errno.h>       /* used in mapname() */
  185. #ifdef USE_STRINGS_H
  186. #  include <strings.h>   /* strcpy, strcmp, memcpy, index/rindex, etc. */
  187. #else
  188. #  include <string.h>    /* strcpy, strcmp, memcpy, strchr/strrchr, etc. */
  189. #endif
  190. #ifdef MODERN
  191. #  include <limits.h>    /* GRR:  EXPERIMENTAL!  (can be deleted) */
  192. #endif
  193.  
  194. #ifdef EFT
  195. #  define LONGINT off_t  /* Amdahl UTS nonsense ("extended file types") */
  196. #else
  197. #  define LONGINT long
  198. #endif
  199.  
  200. #ifdef MODERN
  201. #  ifndef NO_STDDEF_H
  202. #    include <stddef.h>
  203. #  endif
  204. #  ifndef NO_STDLIB_H
  205. #    include <stdlib.h>    /* standard library prototypes, malloc(), etc. */
  206. #  endif
  207.    typedef size_t extent;
  208.    typedef void voidp;
  209. #else /* !MODERN */
  210.    LONGINT lseek();
  211. #  ifdef VAXC              /* not fully modern, but does have stdlib.h */
  212. #    include <stdlib.h>
  213. #  else
  214.      char *malloc();
  215. #  endif
  216.    typedef unsigned int extent;
  217.    typedef char voidp;
  218. #  define void int
  219. #endif /* ?MODERN */
  220.  
  221. /* this include must be down here for SysV.4, for some reason... */
  222. #include <signal.h>      /* used in unzip.c, file_io.c */
  223.  
  224. /*---------------------------------------------------------------------------
  225.     Amiga section:
  226.   ---------------------------------------------------------------------------*/
  227.  
  228. #ifdef AMIGA
  229. #  include "amiga/amiga.h"
  230. #  ifndef AZTEC_C
  231. #    include <sys/types.h>      /* off_t, time_t, dev_t, ... */
  232. #    include <sys/stat.h>
  233. #  endif
  234. #  include <fcntl.h>            /* O_BINARY for open() w/o CR/LF translation */
  235. #  define DATE_FORMAT   DF_MDY
  236. #  define lenEOL        1
  237. #  define PutNativeEOL  *q++ = native(LF);
  238. /* #  define USE_FWRITE   if write() returns 16-bit int */
  239. #  define PIPE_ERROR (errno == 9999)    /* always false */
  240. #endif
  241.  
  242. /*---------------------------------------------------------------------------
  243.     Atari ST section:
  244.   ---------------------------------------------------------------------------*/
  245.  
  246. #if (defined(ATARI_ST) || defined(__MINT__))    /* comments by [cjh] */
  247. #  ifdef __TURBOC__
  248. #    include <ext.h>   /* stat() */
  249. #    include <tos.h>   /* OS-specific functions (Fdup) */
  250. #  endif
  251. #  include <time.h>
  252. #  ifndef __MINT__
  253. #    define dup     Fdup
  254. #    define mkdir   Dcreate
  255. #    define DIR_END '\\'
  256. #  else
  257. #    include <sys/types.h>     /* didn't we include this already? */
  258. #    include <sys/stat.h>
  259. #    include <fcntl.h>         /* O_BINARY */
  260. #    include <unistd.h>        /* dup proto & unix system calls live here */
  261. #    include <time.h>
  262. #    include <stdio.h>         /* didn't we include this already? */
  263. #    define dup dup
  264. #    define mkdir mkdir
  265. #    define DIR_END '/'        /* much sexier than DOS filenames... */
  266. #    define timezone _timezone /* oops */
  267. #    define DIRENT
  268. #    define SYMLINKS
  269. #    ifdef S_ISLNK             /* WARNING:  horrible kludge!!!! */
  270. #      undef S_ISLNK           /* MiNTlibs & POSIX don't define S_ISLNK */
  271. #      define S_ISLNK(a) (((a) & 0xa000) == 0xa000)
  272. #    endif
  273. #    ifdef SHORT_NAMES         /* library will truncate weird names on TOS fs */
  274. #      undef SHORT_NAMES
  275. #    endif
  276. #    ifndef ZMEM
  277. #      define ZMEM             /* we have bcopy, etc., ifndef __STRICT_ANSI__ */
  278. #    endif
  279. #  endif /* __MINT__ */
  280. #  ifndef S_IFMT
  281. #    define S_IFMT     (S_IFCHR | S_IFREG | S_IFDIR)
  282. #  endif
  283. #  define DATE_FORMAT  DF_MDY
  284. #  ifndef lenEOL
  285. #    define lenEOL 2           /* DOS convention; MiNT doesn't